package kr.hkit.powerjava.chapter22.work2;

import java.util.ArrayList;
import java.util.Comparator;

import kr.hkit.powerjava.chapter22.dao.DepartmentManagerImpl;
import kr.hkit.powerjava.chapter22.vo.Department;

public class TestMain2 {
	public static void main(String[] args) {
		ArrayList<Department> deptList = new ArrayList<>();
		DepartmentManagerImpl dm = new DepartmentManagerImpl(deptList);
		
		dm.addItem(new Department(5, "동물학", 3));
		dm.addItem(new Department(3, "생물학", 4));
		dm.addItem(new Department(6, "로봇학", 6));
		dm.addItem(new Department(1, "생체학", 1));
		
		System.out.println("출력");
		dm.prnItems();
		
		System.out.println("수정");
		dm.updateItem(new Department(5,"동물학", 10));
		dm.prnItems();
		
		System.out.println("학과순으로 정렬 (내림차순)");
		dm.prnItems(new Comparator<Department>() {
			@Override
			public int compare(Department o1, Department o2) {
				return o2.getDeptName().hashCode() - o1.getDeptName().hashCode();
			}
		});
		
		
		System.out.println("학과순으로 정렬 (오름차순)");
		dm.prnItems(new Comparator<Department>() {
			@Override
			public int compare(Department o1, Department o2) {
				return o1.getDeptName().hashCode() - o2.getDeptName().hashCode();
			}
		});
		
		System.out.println("학과층 정렬 (내림차순)");
		dm.prnItems(new Comparator<Department>() {
			@Override
			public int compare(Department o1, Department o2) {
				return o2.getFloor() - o1.getFloor();
			}
		});
		
		System.out.println("학과번호 정렬 (오름차순)");
		dm.prnItems(new Comparator<Department>() {
			@Override
			public int compare(Department o1, Department o2) {
				return o1.getDeptNo() - o2.getDeptNo();
			}
		});
		
		
		System.out.println("-------------------------------------");
		System.out.println("검색");
		Department dept = new Department(3, "생물학");
		String result = dm.searchItem(dept) ? "값이 있음" : "값이 없음";
		System.out.println(result);
	}
	
	
	
	
}